﻿/*
 * Last review by   : Yaser
 * Last review date : JUL-21-09
 */
using System;
using ERP.Business.DataTypes.Constants;

namespace ERP.Business.DataTypes.Employee.CV
{
    /// <summary>
    /// Language Entry
    /// </summary>
    [System.Runtime.Serialization.DataContract]
    [Serializable]
    [System.Runtime.Serialization.KnownType(typeof(LanguageEntry))]
    public class LanguageEntry : BaseTypes.BaseType
    {
        #region Constructors

        /// <summary>
        /// Initializes a new instance of the <see cref="LanguageEntry"/> class.
        /// </summary>
        public LanguageEntry() { }

        /// <summary>
        /// Initializes a new instance of the <see cref="LanguageEntry"/> class.
        /// </summary>
        /// <param name="language">The language.</param>
        public LanguageEntry(Constants.Language language)
        {
            Language = language;
        }

        #endregion

        #region Properties

        /// <summary>
        /// Gets or sets the language.
        /// </summary>
        /// <value>The <see cref="Constants.Language"/>.</value>
        [System.Runtime.Serialization.DataMember]
        public Constants.Language Language
        {
            get;
            set;
        }

        /// <summary>
        /// Gets or sets the reading rate.
        /// </summary>
        /// <value>The reading rate as <see cref="Constants.Score"/>.</value>
        [System.Runtime.Serialization.DataMember]
        public Constants.Score ReadingRate
        {
            get;
            set;
        }

        /// <summary>
        /// Gets or sets the communicate rate.
        /// </summary>
        /// <value>The communicate rate as <see cref="Constants.Score"/>.</value>
        [System.Runtime.Serialization.DataMember]
        public Constants.Score CommunicateRate
        {
            get;
            set;
        }

        /// <summary>
        /// Gets or sets the writing rate.
        /// </summary>
        /// <value>The writing rate as <see cref="Constants.Score"/>.</value>
        [System.Runtime.Serialization.DataMember]
        public Constants.Score WritingRate
        {
            get;
            set;
        }

        /// <summary>
        /// Gets or sets the notes.
        /// </summary>
        /// <value>The notes.</value>
        [System.Runtime.Serialization.DataMember]
        public string Notes
        {
            get;
            set;
        }

        #endregion

        #region Methods

        /// <summary>
        /// Determines whether the specified <see cref="System.Object"/> is equal to this instance.
        /// </summary>
        /// <param name="obj">The <see cref="System.Object"/> to compare with this instance.</param>
        /// <returns>
        /// 	<c>true</c> if the specified <see cref="System.Object"/> is equal to this instance; otherwise, <c>false</c>.
        /// </returns>
        public override bool Equals(object obj)
        {
            if (ERP.Framework.Components.Utilities.ComparingHelper.ComapringManager.CompareTypes(this, obj))
                return Language.Equals(((LanguageEntry)obj).Language);
            return false;
        }

        /// <summary>
        /// Compares two objects and returns a value indicating whether one is less than, equal to, or greater than the other.
        /// </summary>
        /// <param name="x">The first object to compare.</param>
        /// <param name="y">The second object to compare.</param>
        /// <returns>
        /// A signed integer that indicates the relative values of <paramref name="x"/> and <paramref name="y"/>, as shown in the following table.Value Meaning Less than zero <paramref name="x"/> is less than <paramref name="y"/>. Zero <paramref name="x"/> equals <paramref name="y"/>. Greater than zero <paramref name="x"/> is greater than <paramref name="y"/>.
        /// </returns>
        /// <exception cref="T:System.ArgumentException">Neither <paramref name="x"/> nor <paramref name="y"/> implements the <see cref="T:System.IComparable"/> interface.-or- <paramref name="x"/> and <paramref name="y"/> are of different types and neither one can handle comparisons with the other. </exception>
        public override int Compare(object x, object y)
        {
            if (ERP.Framework.Components.Utilities.ComparingHelper.ComapringManager.CompareTypes(x, y))
                return ((LanguageEntry)x).Language.CompareTo(((LanguageEntry)y).Language);
            return -1;
        }

        #endregion
    }
}
